package 晚间作业0310;

public class Doc08 {
    // 01题
    public static class Q01 {
        public static abstract class Car {
            protected String mark;

            public Car(String mark) {
                this.mark = mark;
            }

            public abstract void drive();
        }

        public static class SubCar extends Car {
            private String price;
            private int speed;

            public SubCar(String mark, String price) {
                super(mark);
                this.price = price;
            }

            @Override
            public void drive() {
                System.out.println("开上了我心爱的" + mark + ", 它的速度是：" + speed + ", 它的价格是：" + price);
            }

            public void speedChange(int newSpeed) {
                this.speed = newSpeed;
            }
        }

        public static class E {
            public static void main(String[] args) {
                SubCar aodi = new SubCar("aodi", "2290000");
                SubCar benchi = new SubCar("benchi", "2291111");

                aodi.speedChange(100);
                benchi.speedChange(90);

                aodi.drive();
                benchi.drive();
            }
        }
    }

    // 02题
    public static class P02 {
        public static class Shape {
            protected double area;
            public double calculateArea() {
                return -1;
            }
        }

        public static class Circle extends Shape {
            private double radius;

            public Circle(double radius) {
                this.radius = radius;
            }

            @Override
            public double calculateArea() {
                return Math.PI * radius * radius;
            }
        }

        public static class Rectangle extends Shape {
            private double width;
            private double height;

            public Rectangle(double width, double height) {
                this.width = width;
                this.height = height;
            }

            @Override
            public double calculateArea() {
                return width * height;
            }
        }

        public static void main(String[] args) {
            Shape circle = new Circle(5);
            Shape rect = new Rectangle(3, 4);

            System.out.println(circle.calculateArea());
            System.out.println(rect.calculateArea());
        }
    }

    // 03题
    public static class P03 {
        public static class Person {
            protected String name;
            protected String gender;
            protected String age;
            protected String nationality;

            public Person(String name, String gender, String age, String nationality) {
                this.name = name;
                this.gender = gender;
                this.age = age;
                this.nationality = nationality;
            }

            public void actionSleep() {
                System.out.println(name + "睡觉了");
            }

            public void actionEat() {
                System.out.println(name + "吃饭了");
            }

            public void work() {
                // do nothing
            }
        }

        public static class Student extends Person {
            private String school;
            private String sNumber;

            public Student(String name, String gender, String age, String nationality, String school, String sNumber) {
                super(name, gender, age, nationality);
                this.school = school;
                this.sNumber = sNumber;
            }

            @Override
            public void work() {
                System.out.println("学习ing");
            }
        }

        public static class Cadres extends Student {
            private String title;

            public Cadres(String name, String gender, String age, String nationality, String school, String sNumber, String title) {
                super(name, gender, age, nationality, school, sNumber);
                this.title = title;
            }

            @Override
            public void work() {
                System.out.println(title + "，协调工作");
            }

            public void meet() {
                System.out.println("开会");
            }
        }

        public static class Worker extends Person {
            private String company;
            private String workTime;

            public Worker(String name, String gender, String age, String nationality, String company, String workTime) {
                super(name, gender, age, nationality);
                this.company = company;
                this.workTime = workTime;
            }

            @Override
            public void work() {
                System.out.println("写代码");
            }
        }

        public static void main(String[] args) {
            Person student = new Student("小明", "男", "15", "中国", "师大附中", "2014011647");
            Person worker = new Worker("老王", "男", "35", "中国", "京东", "10年");
            Cadres cadres = new Cadres("小红", "女", "35", "中国", "京东", "10年", "班长");

            student.work();
            worker.work();

            cadres.work();
            cadres.meet();
        }
    }

    // 04题
    public static class P04 {
        public static class Disciple {
            public void eat() {
                System.out.println("吃斋");
            }
            public void chant() {
                System.out.println("念佛");
            }
            public void qujing() {
                System.out.println("取经");
            }
        }
        public static class SunWuKong extends Disciple {
            public Disciple killDemon() {
                System.out.println("除妖");
                return this;
            }
        }
        public static class ZhuBaJie extends Disciple {
            public Disciple horse() {
                System.out.println("牵马");
                return this;
            }
        }
        public static class ShaHeShang extends Disciple {
            public Disciple pickUp() {
                System.out.println("挑行李");
                return this;
            }
        }

        public static void main(String[] args) {
            new SunWuKong().killDemon().qujing();
            new ZhuBaJie().horse().qujing();
            new ShaHeShang().pickUp().qujing();
        }
    }
}
